<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入1-100之间的整数">
<input type="button" value="猜一猜" onclick="f()">
<div></div>

<script>
  //得到1-100的随机整数
  let x = parseInt(Math.random()*100)+1;
  let y = document.querySelector("input")
  let z = document.querySelector("div")
  let c = 0
  function f() {
      c++;
    if (y.value < x){
        z.innerText = "小了"
    }else if (y.value > x){
        z.innerText = "大了"
    }else {
        z.innerText = "恭喜"+c+"次答对了！！！"
    }
    y.value=""
  }
</script>
</body>
</html>